// by Jens Schmidt 2009
// for: YOU
// use, modify, copy this as you like

function PasswordAssistant() {
}

PasswordAssistant.prototype.setup = function() {
	
	this.controller.setupWidget(Mojo.Menu.appMenu,
       	this.attributes = {
                omitDefaultItems: true
            },
    	this.model = {
        visible: true,
        items: [Mojo.Menu.editItem]
		});
		
	this.controller.setupWidget("Pass",
         this.attributes = {
             hintText: $L('Enter password here'),
             multiline: false,
             enterSubmits: true,
			 focusMode: Mojo.Widget.focusSelectMode,
			 maxLength: 32,
			 width: 125
         },
         this.model = {
             value: ''
    });
	
    this.controller.setupWidget("Yes", this.buttonAttributes,
		{"label" : "OK",
    	"buttonClass" : 'affirmative',
    	"disabled" : false
   		}
	);
    Mojo.Event.listen(this.controller.get("Yes"), Mojo.Event.tap, this.ok.bind(this));
	
    this.controller.setupWidget("No", this.buttonAttributes,
		{"label" : "Cancel",
    	"buttonClass" : 'negative',
    	"disabled" : false
   		}
	);
    Mojo.Event.listen(this.controller.get("No"), Mojo.Event.tap, this.cancel.bind(this));
}

PasswordAssistant.prototype.activate = function(event) {
	this.controller.get("Note").update('To continue you must enter you account password.<br />The password will not be stored.<br />You can permanently store your password in the preferences.');
}


PasswordAssistant.prototype.deactivate = function(event) {
}

PasswordAssistant.prototype.cleanup = function(event) {
}

PasswordAssistant.prototype.ok = function(event) {
	this.controller.stageController.popScene(this.controller.get("Pass").mojo.getValue())
}

PasswordAssistant.prototype.cancel = function(event) {
	this.controller.stageController.popScene()
}